
/*
 * @Author: ljkt
 * @Version: 2.0
 * @Date: 2021-12-01 14:27:01
 * @LastEditors: ljkt
 * @LastEditTime: 2025-06-30 10:56:26
 * @Description:
 */

#include "./Common_Include.h"
#ifdef EN_IOI
Ram s_drv_ioi_t gDrvIoI[e_INDEX_IOI_MAX], gDrvIoILast[e_INDEX_IOI_MAX];
CONST s_hal_ioi_config_t ioi_config_tab[e_INDEX_IOI_MAX] = DRV_IOI_CONFIG_TAB;
void Drv_IoI_Init(void)
{
    unsigned char i;
    s_hal_ioi_config_t *ioi_config = ioi_config_tab;
    memset(&gDrvIoI, 0, sizeof(gDrvIoI));
    memset(&gDrvIoILast, 0, sizeof(gDrvIoILast));
    for (i = 0; i < ARR_CNT(ioi_config_tab); i++)
    {
        Hal_Gpio_In(&ioi_config->gpio);
        ioi_config++;
    }
}

void Drv_IoI_Scan(void)
{
    static unsigned char tick = 0;
    unsigned char i;
    s_hal_ioi_config_t *ioi_config = ioi_config_tab;
    if (Drv_Autoload_Ntick_u8(&tick, 10ul))
    {
        for (i = 0; i < ARR_CNT(ioi_config_tab); i++)
        {
            gDrvIoI[i].LvBo = gDrvIoI[i].LvBo << 1ul;
            if (ioi_config_tab[i].level == Hal_Gpio_Get(&ioi_config->gpio))
            {
                gDrvIoI[i].LvBo |= 0x01ul;
            }
            if (gDrvIoI[i].LvBo == 0xff)
            {
                gDrvIoI[i].State = 1;
            }
            else if (gDrvIoI[i].LvBo == 0x00)
            {
                gDrvIoI[i].State = 0;
            }
            ioi_config++;
        }
    }
}
#endif